<?php

namespace app\admin\model;

use think\Model;
use traits\model\SoftDelete;

class Ohcard extends Model
{

    use SoftDelete;

    

    // 表名
    protected $name = 'ohcard';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = 'deletetime';

    // 追加属性
    protected $append = [
        'type_text',
        'is_adult_text'
    ];
    

    
    public function getTypeList()
    {
        return ['1' => __('Type 1'), '2' => __('Type 2'), '3' => __('Type 3')];
    }

    public function getIsAdultList()
    {
        return ['1' => __('Is_adult 1'), '0' => __('Is_adult 0')];
    }


    public function getTypeTextAttr($value, $data)
    {
        $value = $value ?: ($data['type'] ?? '');
        $list = $this->getTypeList();
        return $list[$value] ?? '';
    }


    public function getIsAdultTextAttr($value, $data)
    {
        $value = $value ?: ($data['is_adult'] ?? '');
        $list = $this->getIsAdultList();
        return $list[$value] ?? '';
    }




}
